From 129ce53c295acf58603bf0869e39722aaf7b61d5 Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Mon, 19 Dec 2016 10:52:50 +1300 Subject: [PATCH] Test for cargo check with macro and both lib and bin. Closes #3419 --- tests/check.rs | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/tests/check.rs b/tests/check.rs index 3361761d0..9438d9fca 100644 --- a/tests/check.rs +++ b/tests/check.rs @@ -3,6 +3,7 @@ extern crate hamcrest; use cargotest::is_nightly; use cargotest::support::{execs, project}; +use cargotest::support::registry::Package; use hamcrest::assert_that; #[test] @@ -238,3 +239,57 @@ fn issue_3418() { execs().with_status(0) .with_stderr_does_not_contain("--crate-type lib")); } + +// Some weirdness that seems to be caused by a crate being built as well as +// checked, but in this case with a proc macro too. +#[test] +fn issue_3419() { + if !is_nightly() { + return; + } + + let foo = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [dependencies] + rustc-serialize = "*" + "#) + .file("src/lib.rs", r#" + extern crate rustc_serialize; + + use rustc_serialize::Decodable; + + pub fn take() {} + "#) + .file("src/main.rs", r#" + extern crate rustc_serialize; + + extern crate foo; + + #[derive(RustcDecodable)] + pub struct Foo; + + fn main() { + foo::take::(); + } + "#); + + Package::new("rustc-serialize", "1.0.0") + .file("src/lib.rs", + r#"pub trait Decodable: Sized { + fn decode(d: &mut D) -> Result; + } + pub trait Decoder { + type Error; + fn read_struct(&mut self, s_name: &str, len: usize, f: F) + -> Result + where F: FnOnce(&mut Self) -> Result; + } "#).publish(); + + assert_that(foo.cargo_process("check"), + execs().with_status(0)); +} -- 2.30.2